{template 'common/header'}

{if $operation == 'statistics'}
<ul class="nav nav-tabs">
	<li {if $operation == 'statistics'} class="active" {/if}><a href="{php echo $this->createWebUrl('awardlist',array('op' =>'statistics','eid' => $eid))}">数据统计</a></li>
</ul>
	<div class="main panel panel-default">
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
				<tr>
					<th >活动名称</th>
					<th style="width:200px;">参与人数</th>
					<th style="width:200px;">参与次数</th>
					<th style="width:200px;">中奖人数</th>
					<th style="width:200px;">中奖次数</th>
					<th style="width:200px;">已领奖数</th>
				</tr>
				</thead>
				<tbody>
				{loop $award $row}
				<tr>
					<td>{$row[name]}</th>
					<td>{$row[participateman]}</td>
					<td>{$row[participatenum]}</td>
					<td>{$row[winningman]}</td>
					<td>{$row[winningnum]}</td>
					<td>{$row[winningreceive]}</td>
				</tr>
				{/loop}
				</tbody>
			</table>
			{$pager}
		</div>
	</div>
{/if}
{if $operation == 'display'}
<ul class="nav nav-tabs">
	<li {if $operation == 'display'} class="active" {/if}><a href="{php echo $this->createWebUrl('awardlist',array('op' =>'display','eid' => $eid))}">中奖名单</a></li>
</ul>
<div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
			<input type="hidden" name="eid" value="{$eid}" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">姓名</label>
				<div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
					<input class="form-control" name="realname" type="text" value="{$_GPC['realname']}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">电话</label>
				<div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
					<input class="form-control" name="mobile" type="text" value="{$_GPC['mobile']}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">活动名称</label>
				<div class="col-sm-6 col-md-8 col-lg-8 col-xs-12">
					<select name="rid" class="form-control">
						<option value="" selected="selected">请选择</option>
						{loop $award $row}
						<option value="{$row['id']}"{if $row['id'] == $_GPC['rid']} selected="selected"{/if}>{$row['name']}</option>
						{/loop}
					</select>
				</div>
				<div class="pull-right col-xs-12 col-sm-3 col-md-2 col-lg-2">
					<button type="submit" class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
					<input type="hidden" name="token" value="{$_W['token']}" />
				</div>
			</div>
		</form>
	</div>
</div>

<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<table class="table table-hover">
			<thead class="navbar-inner">
			<tr>
				<th style="width:40px;">ID</th>
				<!--<th>openid</th>-->
				<!--<th>头像</th>-->
				<th style="width:190px;">会员</th>
				<th style="width:150px;">活动名称</th>
				<th style="width:100px;">中奖楼层</th>
				<th style="width:150px;">中奖时间</th>
				<th>奖品</th>
				<th style="width:120px;">真实姓名</th>
				<th style="width:150px;">电话</th>
				<th style="width:120px;">QQ</th>
				<th style="width:150px;">IP</th>
				<th style="width:100px;">操作</th>
			</tr>
			</thead>
			<tbody>
			{loop $list $item}
			<tr>
				<td>{$item[id]}</td>
				<!--<td>{$item[openid]}</td>-->
				<td>
					<div class="clear">
						<div class="pull-left" style="width: 40px;height: 40px; overflow: hidden; border-radius: 50%;">
							<img src="{php echo tomedia($item['avatar'])}" onerror="this.src='../app/resource/images/heading.jpg'" style="width: 100%" />
						</div>
						<div class="pull-left" style="line-height: 40px; margin-left: 10px;">
							{if $item['nickname']!=''}{$item['nickname']}{else}{$item['uid']}{/if}
						</div>
					</div>
				</td>
				<td>{$item[rule][name]}</td>
				<td>{$item[floor]}</td>
				<td>{php echo date('Y-m-d H:i:s', $item[dateline])}</td>
				<td>{$item[award][title]}</td>
				<td>{if $item['realname'] == ''} {else}{$item['realname']}{/if}</td>
				<td>{$item[mobile]}</td>
				<td>{$item[qq]}</td>
				<td>{$item[ip]}</td>
				<td>
					{if empty($item[status])}
					<a class="btn btn-success" href="{php echo $this->createWebUrl('awardlist', array('op' => 'mark', 'wid' => $item['id'], 'status' => 1))}">标记领奖</a><br/>
					{else}
					<a class="btn btn-danger" href="{php echo $this->createWebUrl('awardlist', array('op' => 'mark', 'wid' => $item['id'], 'status' => 0))}">取消领奖</a>
					{/if}
				</td>
			</tr>
			{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
</div>

<form action="{php echo $this->createWebUrl('awardlist',array('op' =>'toexcel','eid' => $eid))}" method="post" class="form-horizontal" role="form1">
	<input type="hidden" name="rid" value="{$_GPC['rid']}" />
	<input type="submit" name="submit" class="btn btn-primary" value="导出到EXCEL"/>
</form>

<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
{elseif $operation == 'view'}

<script language='javascript'>
	function formcheck(){
		if($("#express_name").isEmpty()){
			Tip.focus("express_name","请填写物流公司名称!");
			return false;
		}
		return true;
	}

	$(function(){
		$("#common_corp").change(function(){

			var obj = $(this);
			var sel =obj.find("option:selected");

			$("#express_name").val(  sel.attr("data-name"));
			$("#express_url").val(  sel.val() );
		});

		{if !empty($express['id'])}
			$("#common_corp").val(  "{$express['express_url']}");
			{/if}

			})
</script>
{/if}

{template 'common/footer'}